package top.zhimingw.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import top.zhimingw.pojo.Comment;

import java.util.List;

/**
 * @ClassName: CommentMapper
 * @Description: (Comment)表数据库访问层
 * @Author:zhimingw
 * @Version 1.0
 * @since 2021/6/30 14:42
 */
@Mapper
public interface CommentMapper {
    
    
    /**
    * @Description: 添加Comment
    * @Param: [comment]
    * @return: int
    * @Author: zhimingw
    * @Date: 2021/7/7
    */
    int insert(Comment comment);
    
    /**
    * @Description: 根据文章ID和类型获取文章
    * @Param: [aId, type]
    * @return: java.util.List<top.zhimingw.pojo.Comment>
    * @Author: zhimingw
    * @Date: 2021/6/30
    */
    List<Comment> queryByArticleIdAndType(@Param("aId") Integer aId,@Param("type") Integer type);


    /**
    * @Description: 获取所有回复的文章
    * @Param: [id]
    * @return: java.util.List<top.zhimingw.pojo.Comment>
    * @Author: zhimingw
    * @Date: 2021/6/30
    */
    List<Comment> queryReplyComment(Integer id);
    
    /**
    * @Description: 获取评论的数量
    * @Param: []
    * @return: java.lang.Integer
    * @Author: zhimingw
    * @Date: 2021/7/5
    */
    Integer getCount();

    /**
    * @Description: 获取未读评论的数量
    * @Param: []
    * @return: java.lang.Integer
    * @Author: zhimingw
    * @Date: 2021/7/5
    */
    Integer getUnReadCount();
    
    /**
    * @Description: 查询单条数据
    * @Param: [id]
    * @return: top.zhimingw.pojo.Comment
    * @Author: zhimingw
    * @Date: 2021/7/6
    */
    Comment queryById(Integer id);
    
    /**
    * @Description: 实体作为筛选条件查询数据
    * @Param: [comment]
    * @return: java.util.List<top.zhimingw.pojo.Comment>
    * @Author: zhimingw
    * @Date: 2021/7/6
    */
    List<Comment> queryAll(Comment comment);
    
    /**
    * @Description: 修改Comment,根据 comment 的主键修改数据
    * @Param: [comment]
    * @return: int
    * @Author: zhimingw
    * @Date: 2021/7/7
    */
    int update(Comment comment);

    /**
    * @Description: 通过文章id获取评论数量
    * @Param: [id]
    * @return: int
    * @Author: zhimingw
    * @Date: 2021/7/7
    */
    int queryByArticleId(Integer id);
    
    /**
    * @Description: 删除Comment
    * @Param: [id]
    * @return: int
    * @Author: zhimingw
    * @Date: 2021/7/16
    */
    int deleteByArticleId(Integer id);

    /**
    * @Description: 删除Comment
    * @Param: [id]
    * @return: int
    * @Author: zhimingw
    * @Date: 2021/7/20
    */
    int deleteById(Integer id);

    /**
    * @Description: 删除Comment
    * @Param: [id]
    * @return: int
    * @Author: zhimingw
    * @Date: 2021/7/20
    */
    int deleteByReplyId(Integer id);
}
